package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Lxsfy;
import cn.gson.fengboot.model.service.LxsfyService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/vue")
public class LxsfyController {

    @Autowired
    LxsfyService lxsfyService;

    //查询销售费用记录
    @RequestMapping("/cxxsfy")
    @ResponseBody
    public Map<String,Object> cxxsfy(Integer currentPage , Integer pageSize,String search, String fenlei){
        if(currentPage==null || currentPage==' '||pageSize==null||pageSize==' '){
            currentPage=1;
            pageSize=5;
        }
        Page<Object> obj= PageHelper. startPage( currentPage, pageSize);
        List<Lxsfy> lxsfyList = lxsfyService.cxxsfy(search,fenlei);
        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("row",lxsfyList);
        return map;
    }


    //新增销售费用记录
    @RequestMapping("/addlxsfy")
    @ResponseBody
    public  void addlxsfy(@RequestBody Lxsfy lxsfy){
        lxsfyService.addlxsfy(lxsfy);
    }

    //圆形统计图
    @RequestMapping("/xsfyfb")
    @ResponseBody
    public Map<String ,Object> xsfyfb(String vv){
        Map<String,Object> map= null;
        if (vv.equals("全员费用/人员分布（已审核）")){
            map= lxsfyService.xsfyfb();
        }else if (vv.equals("费用类别分布")){
            map= lxsfyService.xsfylbfb();
        }
        return map;
    }

    //柱形统计图
    @RequestMapping("/zhuxing")
    @ResponseBody
    public Map<String ,Object> ygfytj(String vv){
        Map<String,Object> map= lxsfyService.ygfytj();
        if (vv.equals("全员费用/人员分布（已审核）")){
            map= lxsfyService.ygfytj();
        }else if (vv.equals("月度费用申报统计")){
            map=lxsfyService.ygfytj();
        }else if (vv.equals("月度费用审核统计")){
            map= lxsfyService.ygfytj();
        }else if (vv.equals("客户费用（已审核）top20")){
            map= lxsfyService.dykhxsfy();
        }
        return map;
    }

    //柱形统计图
    @RequestMapping("/zhexian")
    @ResponseBody
    public Map<String ,Object> zhexian(String vv){
        Map<String,Object> map= null;
        if (vv.equals("全员费用/人员分布（已审核）")){
            map= lxsfyService.ygfytj();
        }else if (vv.equals("费用类别统计")){
            map= lxsfyService.lbfytj();
        }
//        else if (vv.equals("月度费用审核统计")){
//            map= lxsfyService.xsfylbfb();
//        }
        return map;
    }



}
